package com.atguigu.locks.controller;

import com.atguigu.locks.service.RedissonLockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : leimingchao
 * @date Date : 2021年11月28日 10:04
 */
@RestController
public class LockTestController {

    @Autowired
    private RedissonLockService redissonLockService;

    @GetMapping(value = "/go")
    public Boolean go() {
        return redissonLockService.go();
    }

    @GetMapping(value = "/lockDoor")
    public String lockDoor() {
        Boolean flag = redissonLockService.lockDoor();
        return flag ? "锁门了" : "门没锁";
    }

    @GetMapping(value = "/release")
    public Boolean release() {
        return redissonLockService.release();
    }

    @GetMapping(value = "/park")
    public Boolean park() {
        return redissonLockService.park();
    }

    @GetMapping(value = "/read")
    public String read() {
        return redissonLockService.read();
    }

    @GetMapping(value = "/write")
    public String write() {
        return redissonLockService.write();
    }

    @GetMapping(value = "/lock")
    public Boolean lock() {
        return redissonLockService.lock();
    }

    @GetMapping(value = "/unlock")
    public String unlock() {
        redissonLockService.unlock();
        return "ok";
    }
}
